var getinfo = function(){
    Handlebars.registerHelper("select",function(param, options){
        if(param == 0){
            return options.fn(this);
        }else{
            return options.inverse(this);
        }
    });

    //获取答案列表
    $(function(){
        $.ajax({
            type:"POST",
            url:WebSite.AskerSolvedPage.searchquestion_detail,
            dateType:"json",
            data : {
                "pk_question" : getUrlParam("pk_question")
            },
            success:function(result){
                var answerInfo = result;
                var myTemplate = Handlebars.compile($("#answerinfo_template").html());
                $("#div_answer").html(myTemplate(answerInfo));
            },
            error:function(){
                "该问题暂时还没有人来回答 T_T"
            }
        });
    });

    //采纳后跳到该页面，获得采纳及未采纳的答案
    var pk_answer = getUrlParam("pk_answer");
    var new_pk_question = null;
    if(pk_answer == null){
        //不重新发送ajax
    }else{
        //WebSite.debug("我获得了一个pk_answer");
        //做采纳答案的操作，然后
        $.ajax({
            type:"POST",
            url:WebSite.AskerSolvedPage.adopt_answer,
            dateType:"json",
            data : {
                "pk_sool_answer" : getUrlParam("pk_answer")
            },
            success:function(result){
                if(result.success){
                    var questionInfor = result.resultData;
                    new_pk_question = questionInfor.pk_sool_question;
                    //根据返回的pk_question异步刷新页面
                    $.ajax({
                        type:"POST",
                        url:WebSite.AskerSolvedPage.searchquestion_detail,
                        dateType:"json",
                        data : {
                            "pk_question" : new_pk_question
                        },
                        success:function(result){
                            var answerInfo = result;
                            var myTemplate = Handlebars.compile($("#answerinfo_template").html());
                            $("#div_answer").html(myTemplate(answerInfo));
                        },
                        error:function(){
                            "该问题暂时还没有人来回答 T_T"
                        }
                    });
                }else{
                    alert(result.msg);
                }

            },
            error:function(){
                "该问题暂时还没有人来回答 T_T"
            }
        });
        //然后根据返回的pk_question异步刷新页面
        $.ajax({
            type:"POST",
            url:WebSite.AskerSolvedPage.searchquestion_detail,
            dateType:"json",
            data : {
                "pk_question" : new_pk_question
            },
            success:function(result){
                var answerInfo = result;
                var myTemplate = Handlebars.compile($("#answerinfo_template").html());
                $("#div_answer").html(myTemplate(answerInfo));
            },
            error:function(){
                "该问题暂时还没有人来回答 T_T"
            }
        });
    }

};

//改变时间格式
Handlebars.registerHelper("transdate", function(str,options) {
    return new Date(str).toLocaleString().replace(/\//g, "-");
});

//显示回答人的类型
Handlebars.registerHelper("transtype", function(type, options){
    if(type == 1){
        return options.fn(this);
    }else if(type == 2){
        return options.inverse(this);
    }
});

